package com.one.common.common.stateview;

import androidx.annotation.NonNull;

import com.one.common.R;
import com.one.common.common.stateview.item.ErrorItem;
import com.one.common.utils.StringUtils;
import com.one.common.view.multitytype.adapter.BaseItemBinder;
import com.one.common.view.multitytype.adapter.BaseViewHolderMulti;

/**
 * Author: zhulunjun
 * Email: zhulunjun@qq.com
 * CreateDate: 2018/12/1 15:32
 * Description：错误的通用view
 **/
public class ErrorBinder extends BaseItemBinder<ErrorItem> {
    public ErrorBinder() {
        super(R.layout.layout_state_error);
    }

    @Override
    protected void bindView(@NonNull BaseViewHolderMulti holder, @NonNull ErrorItem item) {
        if (StringUtils.isNotBlank(item.getErrorStr())) {
            holder.setText(R.id.tv_error, item.getErrorStr());
        }

        if (item.getErrorRes() != -1) {
            holder.setImageResource(R.id.iv_error, item.getErrorRes());
        }
    }
}
